/**
 * 
 * 2014-6-11
 */
package com.thinkgem.jeesite.common.pojo.serials.mapper.file;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

import com.thinkgem.jeesite.common.pojo.serials.mapper.obj.ObjSerialize;

public class FileSerialize extends ObjSerialize {

	public static void main(String[] args) {
		FileSerialize ser = new FileSerialize();
		ser.savePerson();
		ser.restorePerson();
	}

	public void savePerson() {
		// Person myPerson = new Person("Jay", 24);
		try {
			FileOutputStream fos = new FileOutputStream("E:\\person.txt");
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			System.out.println("Person--Jay,24---Written");

			// oos.writeObject(myPerson);
			oos.flush();
			oos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void restorePerson() {
		try {
			// FileInputStream fls = new FileInputStream("E:\\person.txt");
			// ObjectInputStream ois = new ObjectInputStream(fls);

			// Person myPerson = (Person)ois.readObject();
			System.out.println("\n---------------------\n");
			System.out.println("Person --read:");
			// System.out.println("Name is:"+myPerson.getName());
			// System.out.println("Age is :"+myPerson.getAge());

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
